package lhc.alg.top100;

/**
 * description: https://leetcode.cn/problems/sort-colors/
 *  颜色分类 直接单指针吧 快排也行
 * author: hongchen.liao
 * date:  2022/8/7
 */
public class _75_Sort_Colors {

    class Solution {
        public void sortColors(int[] nums) {
            int n = nums.length;
            int ptr = 0;
            for(int i = 0; i < n; i++){
                if(nums[i] == 0){
                    int temp = nums[i];
                    nums[i] = nums[ptr];
                    nums[ptr] = temp;
                    ptr++;
                }
            }
            for(int i = ptr; i < n; i++){
                if(nums[i] == 1){
                    int temp = nums[i];
                    nums[i] = nums[ptr];
                    nums[ptr] = temp;
                    ptr++;
                }
            }
        }
    }


}
